﻿CREATE FUNCTION [audit].[GetTraceID]
(@TraceName VARCHAR (50))
RETURNS INT
AS
BEGIN
	DECLARE @ReturnValue int

	SELECT @ReturnValue = [traceid]
	FROM :: fn_trace_getinfo(default)
	WHERE (CAST([value] As nvarchar(255)) LIKE '%' + @TraceName + '%')

	RETURN(@ReturnValue)
END